package com.yequan.thread.timer.scheduleatfixedrate;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class Test {

    static class MyTask extends TimerTask {
        @Override
        public void run() {
            try {
                System.out.println("begin :" + System.currentTimeMillis());
                Thread.sleep(5000);
                System.out.println("end   :" + System.currentTimeMillis());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        MyTask myTask = new MyTask();
        Calendar calendar = Calendar.getInstance();
        Date runDate = calendar.getTime();
        Timer timer = new Timer();
        timer.scheduleAtFixedRate(myTask,3000,3000);
    }

}
